﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace OpenPhotoAlbum.Controls
{
	public class AlbumSiteMapProvider: StaticSiteMapProvider
	{
		private SiteMapNode _rootNode = null;
		private SiteMapNode _lastNode = null;

		public override SiteMapNode BuildSiteMap()
		{
			return _rootNode;
		}

		protected override SiteMapNode GetRootNodeCore()
		{
			return _rootNode;
		}

		public override SiteMapNode RootNode
		{
			get { return _rootNode; }
		}

		public void AppendSiteMapNode(string title, string url)
		{
			SiteMapNode node = new SiteMapNode(this, url, url, title);

			if (_rootNode == null)
			{
				AddNode(node);
				_rootNode = node;
			}
			else
			{
				AddNode(node, _lastNode);
			}
			_lastNode = node;
		}

		public void ClearAllNodes()
		{
			Clear();
			_rootNode = null;
			_lastNode = null;
		}
	}
}
